const appid = `wxaadbab9d13edff20`
const account = `420123485`
const password = `mgkj8888`

const channel = 1
const authType = 2

const url = `http://202.189.5.105:7899/api/auth?account=${account}&pwd=${password}&appId=${appid}&channel=${channel}&authType=${authType}&url=https://open.weixin.qq.com/connect/confirm?uuid=011ze7Gn25MqFa1O`


const axios = require('axios')


let i = 0;
const wait = (n)=>{
    return new Promise((resolve, reject)=>{
        setTimeout(resolve, 500)
    })
}
const get = async ()=>{
    const startTime = new Date().getTime()
    return await axios.post(url).then(res=>res.data).then(async res=>{
        if(res.code === 20001 && !res.Flag && res.message === '授权失败' ){
            i+=1;
            await wait(1000)
            console.log(`第${i}次请求失败, 花费时间${new Date().getTime() - startTime}ms`)
            await get()
        }
        console.log(res)
    }).catch(async e=>{
        await wait(1000)
        console.log(`第${i}次请求失败, 花费时间${new Date().getTime() - startTime}ms`)
        await get()
    })
}

get();